<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of localSum</title>
  <meta name="keywords" content="localSum">
  <meta name="description" content="Fast routine for box filtering.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html images -->
<h1>localSum
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Fast routine for box filtering.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function I = localSum( I, dims, shape, op ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Fast routine for box filtering.

 Same effect as calling 'C=convn( I, ones(dims), shape)', except more
 efficient. Computes local sums by using running sums. To get sum in
 non-overlapping windows, use shape='block'. Equivalent to doing localSum,
 and then subsampling (except more efficient). If operation op is set to
 'max' or 'min', computes local maxes or mins instead of sums.

 USAGE
  I = localSum( I, dims, [shape], [op] )

 INPUTS
  I       - matrix to compute sum over
  dims    - size of volume to compute sum over, can be scalar
  shape   - ['full'] 'valid', 'full', 'same', or 'block'
  op      - ['sum'] 'max', or 'min'

 OUTPUTS
  C       - matrix of sums

 EXAMPLE - 1
  A=rand(500,500,1); dim=25; f=ones(dim,1); shape='same'; r=20;
  tic, for i=1:r, B = localSum(A,dim,shape); end; toc
  tic, for i=1:r, C = conv2(conv2(A,f,shape),f',shape); end; toc
  diff=B-C; im(diff), sum(abs(diff(:)))

 EXAMPLE - 2
  load trees; I=ind2gray(X,map); figure(1); im(I);
  I1=localSum(I,3,'block','sum'); figure(2); im(I1); title('sum')
  I2=localSum(I,3,'block','max'); figure(3); im(I2); title('max')
  I3=localSum(I,3,'block','min'); figure(4); im(I3); title('min')

 See also <a href="imShrink.html" class="code" title="function I = imShrink( I, ratios )">IMSHRINK</a>

 Piotr's Image&amp;Video Toolbox      Version 2.53
 Copyright 2010 Piotr Dollar.  [pdollar-at-caltech.edu]
 Please email me if you find bugs, or have suggestions or questions!
 Licensed under the Lesser GPL [see external/lgpl.txt]</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="../images/private/nlfiltersep.html" class="code" title="function I = nlfiltersep( I, dims, shape, fun, varargin )">nlfiltersep</a>	Efficient multidimensional nonlinear but seperable filtering operation.</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="../filters/modefilt1.html" class="code" title="function y = modefilt1( x, s )">modefilt1</a>	One-dimensional mode filtering.</li><li><a href="imShrink.html" class="code" title="function I = imShrink( I, ratios )">imShrink</a>	Used to shrink a multidimensional array I by integer amount.</li><li><a href="maskCircle.html" class="code" title="function mask = maskCircle( angleStart, angleSiz, r, nSamples )">maskCircle</a>	Creates an image of a 'pie slice' of a circle.</li><li><a href="normxcorrn.html" class="code" title="function C = normxcorrn( T, A, shape, Tm )">normxcorrn</a>	Normalized n-dimensional cross-correlation.</li><li><a href="optFlowCorr.html" class="code" title="function [Vx,Vy,reliab] = optFlowCorr( I1, I2, patchR, searchR,sigma, thr, show )">optFlowCorr</a>	Calculate optical flow using cross-correlation.</li><li><a href="optFlowLk.html" class="code" title="function [Vx,Vy,reliab]=optFlowLk( I1, I2, winN,winSig, sigma, thr, show )">optFlowLk</a>	Calculate optical flow using Lucas & Kanade.  Fast, parallel code.</li><li><a href="xeucn.html" class="code" title="function C = xeucn( A, T, shape )">xeucn</a>	n-dimensional euclidean distance between each window in A and template T.</li></ul>
<!-- crossreference -->




<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
